<script>
// var tea_name = document.getElementById("tea_name");
// tea_name.onblur = function() {

// <?php 
// function tea_name() {
//     $tea_name = $_POST["tea_name"];

//     $checkunsql = "select * from teachers where tea_number='$username'";

//     include_once("database.php");

//     $result = @mysql_query($checkunsql) or die("查询同名用户的时候出现错误!");
    
//     $result = mysql_num_rows($result);

//     if($result > 0) {
//         //存在同名记录
//         echo "<font color=\"red\">用户名{$username}已经被注册,请重新填写用户名!</font>";
//     } else {
//         //不存在同名记录
//         echo "<font color=\"green\">用户名{$username}没有被注册,可以使用!</font>";
//     }
// }
        
// ?>
// }
</script>

<?php echo "<script>tea_name();</script>";?>




// $selectteasql = "select * from teachers where tea_name='$tea_name'";

    // include_once("database.php");

    // $result = @mysql_query($selectteasql) or die("查询同名用户的时候出现错误!");
    
    // $result = mysql_num_rows($result);

    // if($result > 0) {
    //     //存在同名记录
    //     echo "<font color=\"red\">用户名{$username}已经被注册,请重新填写用户名!</font>";
    // } else {
        //不存在同名记录
        // echo "<font color=\"green\">用户名{$username}没有被注册,可以使用!</font>";











        // 学生
    if(isset($_GET["action"]) && $_GET["action"] == "student") {

        $stu_number = $_POST["stu_number"];
        $stu_password = $_POST["stu_password"];

	    $selectstusql = "select * from students where stu_number='$stu_number' and stu_password='$stu_password'";
	
	    include_once("database.php");

	    $stu_result = @mysql_query($selectstusql) or die("学生登录失败:".mysql_error()."<br/>");

	    if(mysql_num_rows($stu_result) > 0) {
		    //输入的用户名和密码是正确的
		    //写cookie信息
		    setcookie("stu_number",$stu_number,time()+60*60*24*7);
		    //跳转页面到主界面
		    // header("refresh:1;url=student/index.php");
            header("Location:student/notice.php");

	    } else {
		    //输入的用户名和密码不存在
	        echo "<script>alert(\"用户名或密码错误!\");</script>";
	    }
    }  


    // 管理员
    if(isset($_GET["action"]) && $_GET["action"] == "adminfo") {
        
        $adm_number = $_POST["adm_number"];
        $adm_password = $_POST["adm_password"];

        $selectadmsql = "select * from adminfos where adm_number='$adm_number' and adm_password='$adm_password'";

        $adm_result = @mysql_query($selectadmsql) or die("管理员登录失败:".mysql_error()."<br/>");

        if(mysql_num_rows($adm_result) > 0) {

            setcookie("adm_number",$adm_number,time()+60*60*24*7);
            //跳转页面到主界面
            // header("refresh:1;url=index.php");
            header("Location:adminfo/notice.php");

        } else {
            echo "<script>alert(\"用户名或密码错误!\");</script>";
        }
    }